<template>
	<slot :url="url" :loading="loading"></slot>
</template>

<script lang="ts" setup>
	import { ref } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	const props = defineProps({
	  src: {
		type: String,
		required: true,
	  }
	})
	const url = ref('')
	const loading = ref(true)
	onLoad(async () => {
		if (props.src.substring(0, 8) == "cloud://") {
			const res = await uniCloud.getTempFileURL({
				fileList: [props.src]
			})
			url.value = res.fileList[0].tempFileURL
		} else {
			url.value = props.src
		}
		loading.value = false
	})
</script>
